package com.whiteape.book.ui.adapter;

import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.whiteape.book.R;
import com.whiteape.book.model.dto.MediaChapterBean;

import java.util.List;

public class DetailCatalogAdapter extends BaseQuickAdapter<MediaChapterBean, BaseViewHolder> {


    private String currentChapterId = "";

    public String getCurrentChapterId() {
        return currentChapterId;
    }

    public void setCurrentChapterId(String currentChapterId) {
        this.currentChapterId = currentChapterId;
    }

    public DetailCatalogAdapter(int layoutResId, @Nullable List<MediaChapterBean> data) {
        super(layoutResId, data);
    }


    @Override
    protected void convert(BaseViewHolder helper, MediaChapterBean item) {
        helper.setText(R.id.tv_chapter_name, item.getName());
        if (item.getId().equals(currentChapterId)) {
            helper.getView(R.id.iv_chapter_reading).setVisibility(View.VISIBLE);
        } else {
            helper.getView(R.id.iv_chapter_reading).setVisibility(View.GONE);
        }
        helper.addOnClickListener(R.id.fl_catalog_chapter);
    }
}
